package com.shntec.xtask.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;

import com.shntec.bp.common.BaseSQLHelper;
import com.shntec.bp.common.ShntecBaseDAO;
import com.shntec.bp.util.ShntecLogger;

public class XtaskDateObject extends ShntecBaseDAO{
	
	private final static String THIS_TABLE_NAME = "xtask_tasks";
	private final static String THIS_PRIMARY_KEY_NAME = "tid";
	
	private Integer did = null;
	private Long dateValue = null;
		
	public XtaskDateObject(BaseSQLHelper helper){
		super(helper);
		tableName = THIS_TABLE_NAME;
		primaryKeyName = THIS_PRIMARY_KEY_NAME;
	}
	
	public Integer getDid() {
		return did;
	}

	public void setDid(Integer did) {
		this.did = did;
	}

	public Long getDateValue() {
		return dateValue;
	}

	public void setDateValue(Long dateValue) {
		this.dateValue = dateValue;
	}

	@Override
	protected boolean loadResultSet(ResultSet rs) {
		try {
			
			did = rs.getInt("did");
			dateValue = rs.getLong("dateValue");

		} catch (SQLException e) {
			ShntecLogger.logger.error("Handle database resultset failed, table name=" + getTableName());
			ShntecLogger.logger.error(e.getMessage());
			return false;
		}
		
		return true;
	}

	@Override
	protected HashMap<String, Object> generateColumnList() {
		HashMap<String, Object> columnList = new HashMap<String, Object>();
		
		columnList.put("did", did);
		columnList.put("dateValue", dateValue);
		
		return columnList;
	}

	@Override
	protected void updateResultSet(ResultSet rs) throws SQLException {
		
		updateAllowNullColumns(rs, "dateValue", dateValue);
		
	}
	
	
}
